package de.gwtprime.client.util;

import com.google.gwt.user.client.ui.HTML;

import de.gwtprime.shared.requestFactory.ArticleSectionProxy;
import de.gwtprime.shared.util.AppUtilsShared;

/**
 * Shows a google plus button. To initialize the HTML 5 version, the Method <code>AppUtils.initializeGooglePlusWidget</code> 
 * needs to be called
 * @author jan
 *
 */
public class GooglePlusWidget extends HTML{
	
	/**
	 * Width of the widget in pixels
	 */
	private static int widgetWidth = 200;
	

	public GooglePlusWidget(){
		this(null);
	}
	public GooglePlusWidget(ArticleSectionProxy entity) {
		super(getHTML5Version(entity));
	}
	
	
	/**
	 * The HTML5 version needs the script to be loaded in the host page first
	 * @param entity
	 * @return
	 */
	public static String getHTML5Version(ArticleSectionProxy entity){
		
		String s = "<div class='g-plusone' data-annotation='inline' data-width='"+widgetWidth+"' data-href='"+(entity != null ? AppUtilsShared.convertToFacebookUrl(entity) : AppUtilsShared.DOMAIN_PROD)+"'></div>";
		
		return s;
	}
}
